//
//  HESocketManager.h
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/27.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "HEIMMessageModel.h"
#import "HECircleChatManager.h"

@import SocketIO;

NS_ASSUME_NONNULL_BEGIN

@protocol HESocketManagerDelegate <NSObject>

/// 登录成功回调
- (void)loginSuccessHandler;

/// 收到消息
- (void)onRecvMessages:(HEIMMessageModel *)message;

/// 发送消息
- (void)sendMessage:(HEIMMessageModel *)message error:(NSError * __nullable *)error;

/// 连接异常回调
- (void)onErrorHandler;

/// 断开连接回调
- (void)onDisConnectHandler;

/// 群聊人员更新
- (void)onGroupMemberUpdate:(NSDictionary *)model;

/// 群聊创建、删除
- (void)onGroupCreateAndDelUpdate:(NSDictionary *)model;

@end

@interface HESocketManager : NSObject

@property (nonatomic, strong) SocketIOClient *socket;

@property (nonatomic, weak) HECircleChatManager *circleChatManager;
 
+ (instancetype)sharedManager;

- (void)connect;

- (void)close;

/**
 *  添加聊天委托
 *
 *  @param delegate 聊天委托
 */
- (void)addDelegate:(id<HESocketManagerDelegate>)delegate;

/**
 *  移除聊天委托
 *
 *  @param delegate 聊天委托
 */
- (void)removeDelegate:(id<HESocketManagerDelegate>)delegate;



@end

NS_ASSUME_NONNULL_END
